In an optical system (e.g., a light scanning sensor, distance finding sensor, or background-light sensing system), light emitting diodes (LED) and/or light detectors are used. Alignment of the optical devices is important since the optical axes of an optical device can be greatly affected by misalignment. It is therefore desirable to have a package structure and corresponding method that reduce the misalignment of optical devices in various applications.